<template>
    <div class="list">
        <h1 class="header">{{ title }}</h1>
        <ul class="list-ul">
            <template v-for="item in homeStore.topListData[topListId]" :key="item.index">
                <li>
                    <a class="item" :href="item.link" target="_blank">
                        <span :class="{ 'item-index': true, hotItem: item.index < 11 }">{{ item.index }}</span>
                        <span class="item-title text-elip">{{ item.title }}</span>
                        <span class="item-hotValue">{{ item.hotValue }}</span>
                    </a>
                </li>
            </template>
        </ul>
    </div>
</template>

<script setup lang="ts">
    import { useRoute, useRouter } from "vue-router";
    import { computed, ref } from "vue";
    import { useHomeStore } from "@/store/home";
    import type { TopListId } from "@/api/api_everyday";

    // const props = defineProps<{
    //   title: string;
    //   listData: TopList
    // }>()

    const homeStore = useHomeStore();
    const router = useRouter();
    const route = useRoute();
    const title = ref(route.query.title);

    const topListId = ref<TopListId>(route.query.topListId as TopListId);

    // const handlerClickItem = (link: string) => {
    //
    // }
</script>

<style scoped>
    .list {
        width: 100%;
        max-width: 800px;
        min-height: 100vh;
        margin: 0 auto;
        position: relative;
        padding: 20px;
        color: white;
        z-index: 999;
    }
    .list::after {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        background-color: #0007;
        backdrop-filter: blur(10px);
        z-index: -1;
    }
    .header {
        margin: 20px auto;
        text-align: center;
        font-size: 20px;
        font-weight: bold;
    }
    .item {
        display: flex;
        align-items: center;
        line-height: 34px;
        font-size: 14px;
        color: #fff;
    }
    .item:hover .item-title {
        color: #1890ff;
    }

    .item .item-index {
        width: 18px;
        line-height: 18px;
        margin-right: 10px;
        display: inline-block;
        text-align: center;
        border-radius: 4px;
        font-size: 12px;
        background-color: #282828;
    }
    .item .hotItem {
        background-color: #c20000;
    }
    .item .item-title {
        flex: 1;
        border-bottom: 1px solid #5556;
    }
    .item .item-hotValue {
        margin-left: 10px;
        max-width: 100px;
        height: 22px;
        line-height: 22px;
        overflow: hidden;
        display: inline-block;
        /*margin-right: 20px;*/
    }

    .text-elip {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }
</style>
